package models

//doc --- http://beego.me/docs/mvc/model/orm.md

import (
	"MacroGin/models/item"
	"MacroGin/models/user"
	"fmt"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql" // import your used driver
)

func init() {

	fmt.Println("[init database]......")

	orm.Debug = true
	orm.RegisterDriver("mysql", orm.DRMySQL)
	orm.RegisterModel(new(user.User))
	orm.RegisterModel(new(user.Post))
	orm.RegisterModel(new(item.Item))

	mysql_config := "root:123456@tcp(192.168.47.140:3306)/macrogin?parseTime=true"
	orm.RegisterDataBase("default", "mysql", mysql_config)
	orm.SetMaxIdleConns("default", 240)
	orm.SetMaxOpenConns("default", 240)
	fmt.Println("[end init database]......")

}
